//
//  LSOfficialViewController.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2019/7/25.
//  Copyright © 2019 wpkj. All rights reserved.
//

#import "LSOfficialViewController.h"
#import "LSNiWenManageViewController.h"//拟文管理
#import "LSLevinBookListViewController.h"//来文登记簿
#import "LSYueBanMangeVC.h"
#import "LSYueZhimangerVC.h"
#define ButtonWidth ((ScreenWidth-20)/2-5)

@interface LSOfficialViewController ()
@property (nonatomic, strong) NSArray *buttonsArray;
@end

@implementation LSOfficialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"公文流转";
    [self setUpButtons];
}

- (void)setUpButtons {
    for (int i = 0; i < self.buttonsArray.count; i++) {
        NSInteger row = i/2;
        NSInteger cal = i%2;
        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10+(ButtonWidth+10)*cal, 10+(10+(ButtonWidth/190*120))*row, ButtonWidth, ButtonWidth/190*120)];
        button.tag = TagFoundation+i;
        [button setBackgroundImage:[UIImage imageNamed:self.buttonsArray[i]] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:button];
    }
}

- (void)buttonClicked:(UIButton *)button {
    NSInteger tag = button.tag-TagFoundation;
    switch (tag) {
        case 0:
        {
            // 拟文管理
            LSNiWenManageViewController *niWenManageVC = [[LSNiWenManageViewController alloc] init];
            [self.navigationController pushViewController:niWenManageVC animated:true];
        }
            break;
        case 1:
        {
            // 阅办管理
            LSYueBanMangeVC *lvc = [[LSYueBanMangeVC alloc]init];
            [self.navigationController pushViewController:lvc animated:YES];
        }
            break;
        case 2:
        {
            // 阅知管理
            LSYueZhimangerVC *lvc = [[LSYueZhimangerVC alloc]init];
            [self.navigationController pushViewController:lvc animated:YES];
        }
            break;
        case 3:
        {
            // 来文登记簿
            LSLevinBookListViewController *levinBookVC = [[LSLevinBookListViewController alloc] init];
            [self.navigationController pushViewController:levinBookVC animated:true];
        }
            break;
            
        default:
            break;
    }
}

- (NSArray *)buttonsArray {
    if (!_buttonsArray) {
        _buttonsArray = @[@"pic_nwgl",@"pic_ybgl",@"pic_yzgl",@"pic_lwdj"];
    }
    return _buttonsArray;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
